/*
 * $Id$
 */
package com.cgmnx.admin.dao.entity.rbac;

import com.cgmnx.admin.common.bean.BaseModel;
import com.cgmnx.admin.common.enums.ValidEnumType;
import com.cgmnx.admin.model.enums.rbac.ResourceType;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.apache.commons.lang3.StringUtils;

@Setter
@Getter
@ToString
public class ResourceEntity extends BaseModel {

    public static final String TREE_CODE_SEPARATOR = "#";

    /**
     * 顶级uri的parentId
     */
    public static final int TOP_PARENT_ID = 0;

    /**
     * id
     */
    private Integer id;

    /**
     * 名称
     */
    private String name;
    private String parentName;

    /**
     * 父id
     */
    private Integer parentId;

    /**
     * uri
     */
    private String uri;

    /**
     *
     */
    private String treeCode;

    /**
     *
     */
    private ResourceType showType;

    /**
     * 排序权重wo
     */
    private Integer sort;

    /*
     * 菜单的图标
	 */
    private String icon;

    /*
     * 资源描述
     */
    private String description;

    /**
     * 有效状态
     */
    private ValidEnumType validStatus;

    private Integer nodeCount;

    private Boolean isParent;

    /**
     * 追加treeCode
     *
     * @param code
     * @return
     */
    public ResourceEntity appendTreeCode(String code) {
        this.treeCode = StringUtils.trimToEmpty(this.treeCode) + code + TREE_CODE_SEPARATOR;
        return this;
    }

}
